package com.gmall.product.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gmall.common.result.Result;
import com.gmall.model.product.SpuImage;
import com.gmall.model.product.SpuInfo;
import com.gmall.product.service.SpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/admin/product/")
public class SpuController {


    @Autowired
    SpuService spuService;

    @GetMapping("{pageNo}/{pageSize}")
    public Result<IPage<SpuInfo>> getSpuInfoPageByCategory3Id(@PathVariable Integer pageNo,
                                                 @PathVariable Integer pageSize,
                                                 @RequestParam Map searchMap){
        return spuService.getSpuInfoPageByCategory3Id(pageNo,pageSize,searchMap);
    }
    @PostMapping("saveSpuInfo")
    public Result<String> saveSpuInfo(@RequestBody SpuInfo spuInfo){
        return spuService.saveSpuInfo(spuInfo);
    }

    @PostMapping("testAopTransaction")
    public Result<String> testAopTransaction(){
        return spuService.testAopTransaction();
    }

    @GetMapping("getSpuImageList/{spuId}")
    public Result<List<SpuImage>> getSpuImageList(@PathVariable Long spuId){
        return spuService.getSpuImageList(spuId);
    }


}
